﻿using System;

namespace Infrastructure.ElasticSearch.ParentChilds
{
    public static class DateFormatExtension
    {
        public static string ToDateByElasticSearch(this DateTime? date)
        {
            if (date.HasValue)
            {
                return $"{date.Value:yyyy-MM-dd HH:mm:ss}";
            }
            return null;
        }

        public static string ToDate(this string date)
        {
            if (string.IsNullOrWhiteSpace(date)) return null;
            return date.Trim();
        }
    }
}
